<?php
//require('Header_iframe.php');
include('../db_connect.php');

$view_record=true;
$firstName= $_POST['firstName'];
$lastName= $_POST['lastName'];
if($firstName == "" || is_numeric($firstName)){
	$view_record=false;
    echo "Sorry, could not validate first name.";
    return;
}

if($lastName == "" || is_numeric($lastName)){
	$view_record=false;
    echo "Sorry, could not validate last name.";
    return;
}

//we are validated, search for user record 
if($view_record){ 
	$sql="select * from fb_users where fb_first_name='$firstName' and fb_last_name='$lastName'";
	$result=$db->Execute($sql);
    $num_rec= $result->RecordCount();
    if($num_rec == 0){
        echo "No records for $firstName $lastName exist. Sorry.";
        return;
    }
    //we have some record(s)...display in a table
    echo "<table class=\"small\" cellspacing=\"5\">";
    echo "<tr><td><b>Facebook ID</b></td><td><b>First Name</b></td><td><b>Last Name</b></td> <td><b>ULink ID</b></td> <td><b>Student ID</b></td> <td><b>Tutor?</b></td> <td><b>Admin?</b></td> <td><b>Banned?</b></td></tr>";
    while(!$result->EOF){
            echo "<tr><td>".$result->fields['user_id']."</td><td>".$result->fields['fb_first_name']. "</td><td>".$result->fields['fb_last_name']. "</td><td>".$result->fields['ulink_id']. "</td><td>".$result->fields['student_id']. "</td><td>";
            if($result->fields['reach_tutor']== 1) echo "Yes</td><td>";
            else echo "No</td><td>";
            if($result->fields['reach_admin']== 1) echo "Yes</td><td>";
            else echo "No</td><td>";
            if($result->fields['banned']== 1) echo "Yes</td></tr>";
            else echo "No</td></tr>";
        $result->MoveNext();
    }
    echo "</table>";
}
?>
